home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr44 / newmat08.zip / NEWMATA.TXT < prev    next >
Text File  |  1995-01-20  |  71KB  |  1,881 lines

  1.  
  2.  
  3.         DOCUMENTATION FOR NEWMAT08, A MATRIX LIBRARY IN C++
  4.  
  5. Copyright (C) 1991,2,3,4,5: R B Davies
  6.  
  7. This is the "how to use" documentation for newmat. Background information on
  8. the structure of the library is given in newmatb.txt.
  9.  
  10. This document is available as an ascii file, newmata.txt, and in hypertext
  11. format for reading with "Mosaic". Cross-references in the ascii version are
  12. given as section numbers.
  13.  
  14.  
  15.         Introduction                                 1
  16.         Getting started                              2
  17.         Reference manual                             3
  18.         Error messages                               4
  19.         Bugs                                         5
  20.         Files in newmat08                            6
  21.         Problem report form                          7
  22.  
  23.  
  24.         1  Introduction
  25.         =  ============
  26.  
  27.         Conditions of use                            1.1
  28.         Description                                  1.2
  29.         Is this the library for you?                 1.3
  30.         Other matrix libraries                       1.4
  31.         Where to find this library                   1.5
  32.         How to contact the author                    1.6
  33.         Change history                               1.7
  34.         References                                   1.8
  35.  
  36.  
  37.         1.1  Conditions of use
  38.         ===  ========== == ===
  39.  
  40. Copyright (C) 1991,2,3,4,5: R B Davies.
  41.  
  42. Permission is granted to use and distribute but not to sell except for costs
  43. of distribution. Distribution as part of low cost CD-ROM collections is
  44. welcomed.
  45.  ------------------------------------------------------------------------------
  46. Please understand that there may still be bugs and errors. Use at your own
  47. risk. I take no responsibility for any errors or omissions in this package or
  48. for any misfortune that may befall you or others as a result of its use.
  49.  ------------------------------------------------------------------------------
  50.  
  51. Please report bugs to me at
  52.  
  53.     robert.davies@vuw.ac.nz
  54.  
  55. or
  56.  
  57.     Compuserve 72777,656
  58.  
  59. When reporting a bug please tell me which C++ compiler you are using (if
  60. known), and what version. Also give me details of your computer (if known).
  61. Tell me where you downloaded your version of my package from and its version
  62. number (eg newmat03 or newmat04). (There may be very minor differences between
  63. versions at different sites). Note any changes you have made to my code. If at
  64. all possible give me a piece of code illustrating the bug. See the problem
  65. report form [7].
  66.  
  67. "Please do report bugs to me."
  68.  
  69.  
  70.  
  71.         1.2  General description
  72.         ===  ======= ===========
  73.  
  74. The package is intended for scientists and engineers who need to manipulate a
  75. variety of types of matrices using standard matrix operations. Emphasis is on
  76. the kind of operations needed in statistical calculations such as least
  77. squares, linear equation solve and eigenvalues.
  78.  
  79. It supports matrix types
  80.  
  81.     Matrix                       (rectangular matrix)
  82.     nricMatrix                   (variant of rectangular matrix)
  83.     UpperTriangularMatrix
  84.     LowerTriangularMatrix
  85.     DiagonalMatrix
  86.     SymmetricMatrix
  87.     BandMatrix
  88.     UpperBandMatrix              (upper triangular band matrix)
  89.     LowerBandMatrix              (lower triangular band matrix)
  90.     SymmetricBandMatrix
  91.     RowVector                    (derived from Matrix)
  92.     ColumnVector                 (derived from Matrix).
  93.  
  94. Only one element type (float or double) is supported.
  95.  
  96. The package includes the operations *, +, -, concatenation, inverse,
  97. transpose, conversion between types, submatrix, determinant, Cholesky
  98. decomposition, QR triangularisation, singular value decomposition, eigenvalues
  99. of a symmetric matrix, sorting, fast Fourier transform, printing and an
  100. interface with "Numerical Recipes in C".
  101.  
  102. It is intended for matrices in the range 15 x 15 to the maximum size your
  103. machine will accomodate in a single array. For example 90 x 90 (125 x 125 for
  104. triangular matrices) in machines that have 8192 doubles as the maximum size of
  105. an array. The number of elements in an array cannot exceed the maximum size of
  106. an "int". The package will work for very small matrices but becomes rather
  107. inefficient.
  108.  
  109. A two-stage approach to evaluating matrix expressions is used to improve
  110. efficiency and reduce use of temporary storage.
  111.  
  112. The package is designed for version 2 or 3 of C++. It works with Borland (3.1
  113. & 4.0), Microsoft (7 & 8) and Watcom (10) C++ on a PC and AT&T C++ (2.1 & 3)
  114. and Gnu G++ (2.3.3, 2.5.8 & 2.6.0). It works with some problems with Zortech
  115. C++ (version 3.04).
  116.  
  117.  
  118.  
  119.         1.3  Is this the library for you?
  120.         ===  == ==== === ======= === ====
  121.  
  122. Do you
  123.  
  124. 1:  understand * to mean matrix multiply and not element by element multiply
  125.  
  126. 2:  need matrix operators such as * and + defined as operators so you can
  127. write things like
  128.  
  129.     X  = A * (B + C);
  130.  
  131. 3:  need a variety of types of matrices (but not sparse)
  132.  
  133. 4:  need only one element type (float or double)
  134.  
  135. 5:  work with matrices in the range 10 x 10 up to what can be stored in one
  136. block in memory
  137.  
  138. 6:  tolerate a large package
  139.  
  140.  
  141. Then maybe this is the right package for you. 
  142.  
  143.  
  144.  
  145.         1.4  Other matrix libraries
  146.         ===  ===== ====== =========
  147.  
  148. For commercial packages that support multiple element types, look at M++ from
  149. Dyad [phone in the USA (800)366-1573, (206)637-9427, fax (206)637-9428], or
  150. the Rogue Wave matrix package [(800)487-3217, (503)754-3010, fax
  151. (503)757-6650].
  152.  
  153. For details of other matrix packages look at the listing from Keith Briggs. A
  154. recent version of this is in file kbriggs.txt included with this package. Also
  155. look at Ajay Shah's list of free numerical software in C and C++. The file is
  156. numcomp-free-c.gz in pub/C-numanal on usc.edu. Nikki Locke produces a list of
  157. C++ libraries in general - see
  158. pub/usenet-by-group/comp.lang.c++/c++_FAQ/libraries in rtfm.mit.edu. 
  159.  
  160. Also look on Compuserve in the forums of the various C++ compilers.
  161.  
  162.  
  163.  
  164.         1.5  Where to find this library
  165.         ===  ===== == ==== ==== =======
  166.  
  167.  
  168. *   Compuserve (Borland library, zip format)
  169.  
  170. *   SimTel (msdos.cpluspls directory, zip format) - see oak.oakland.edu
  171.  
  172. *   comp.sources.misc on Internet (shar format) - see wuarchive.wustl.edu
  173.  
  174.  
  175.  
  176.  
  177.         1.6  How to contact the author
  178.         ===  === == ======= === ======
  179.  
  180.  
  181.    Robert Davies
  182.    16 Gloucester Street
  183.    Wilton
  184.    Wellington
  185.    New Zealand
  186.  
  187.    "email:" robert.davies@vuw.ac.nz
  188.  
  189.  
  190.  
  191.  
  192.         1.7  Change history
  193.         ===  ====== =======
  194.  
  195. Newmat08 - January, 1995:
  196.  
  197. Corrections to improve compatibility with Gnu, Watcom. Concatenation of
  198. matrices. Elementwise products. Option to use compilers supporting exceptions.
  199. Correction to exception module to allow global declarations of matrices. Fix
  200. problem with inverse of symmetric matrices. Fix divide-by-zero problem in SVD.
  201. Include new QR routines. Sum function. Non-linear optimisation.
  202. GenericMatrices.
  203.  
  204. Newmat07 - January, 1993
  205.  
  206. Minor corrections to improve compatibility with Zortech, Microsoft and Gnu.
  207. Correction to exception module. Additional FFT functions. Some minor increases
  208. in efficiency. Submatrices can now be used on RHS of =. Option for allowing C
  209. type subscripts. Method for loading short lists of numbers.
  210.  
  211.  
  212. Newmat06 - December 1992:
  213.  
  214. Added band matrices; 'real' changed to 'Real' (to avoid potential conflict in
  215. complex class); Inject doesn't check for no loss of information;  fixes for
  216. AT&T C++ version 3.0; real(A) becomes A.AsScalar(); CopyToMatrix becomes
  217. AsMatrix, etc; .c() is no longer required (to be deleted in next version);
  218. option for version 2.1 or later. Suffix for include files changed to .h; BOOL
  219. changed to Boolean (BOOL doesn't work in g++ v 2.0); modifications to allow
  220. for compilers that destroy temporaries very quickly; (Gnu users - see the
  221. section of compiler performance). Added CleanUp, LinearEquationSolver,
  222. primitive version of exceptions.
  223.  
  224.  
  225. Newmat05 - June 1992:
  226.  
  227. For private release only 
  228.  
  229.  
  230. Newmat04 - December 1991:
  231.  
  232. Fix problem with G++1.40, some extra documentation
  233.  
  234.  
  235. Newmat03 - November 1991:
  236.  
  237. Col and Cols become Column and Columns. Added Sort, SVD, Jacobi, Eigenvalues,
  238. FFT, real conversion of 1x1 matrix, "Numerical Recipes in C" interface, output
  239. operations, various scalar functions. Improved return from functions.
  240. Reorganised setting options in "include.hxx".
  241.  
  242.  
  243. Newmat02 - July 1991:
  244.  
  245. Version with matrix row/column operations and numerous additional functions.
  246.  
  247.  
  248. Matrix - October 1990:
  249.  
  250. Early version of package.
  251.  
  252.  
  253.  
  254.         1.8  References
  255.         ===  ==========
  256.  
  257. The matrix inverse routine and the sort routines are adapted from "Numerical
  258. Recipes in C" by Press, Flannery, Teukolsky, Vetterling, published by the
  259. Cambridge University Press.
  260.  
  261. Many of the advanced matrix routines are adapted from routines in "Handbook
  262. for Automatic Computation, Vol II, Linear Algebra" by Wilkinson and Reinsch,
  263. published by Springer Verlag.
  264.  
  265.  
  266.  
  267.         2  Getting started
  268.         =  ======= =======
  269.  
  270.         Overview                                     2.1
  271.         Customising                                  2.2
  272.         Compiler performance                         2.3
  273.         Updating from previous versions              2.4
  274.         Example                                      2.5
  275.         Testing                                      2.6
  276.  
  277.  
  278.  
  279.  
  280.  
  281.         2.1  Overview
  282.         ===  ========
  283.  
  284. I use .h as the suffix of definition files and .cpp as the suffix of C++
  285. source files.
  286.  
  287. You will need to compile all the *.cpp files except example.cpp, the tmt*.cpp
  288. files, sl_ex.cpp and ex_nl.cpp to get the complete package. Ideally you should
  289. store the resulting object files as a library. The tmt*.cpp files are used for
  290. testing [2.6], example.cpp is an example [2.5] and sl_ex.cpp and ex_nl.cpp are
  291. examples of the non-linear [3.26] solve and optimisation routines.
  292.  
  293. I include a number of "make" files for compiling the example and the test
  294. package. See the files section [6] for details. But with Borland and Watcom,
  295. its pretty quick just to load all the files in the interactive environment by
  296. pointing and clicking. My Borland "make" files are generated from the
  297. interactive environment.
  298.  
  299. Use the large or flat model when you are using a PC. Do not "outline" inline
  300. functions. You may need to increase the stack size.
  301.  
  302. The "make" files for the Unix compilers link a .cxx file to each .cpp file
  303. since some of these compilers do not recognise .cpp as a legitimate extension
  304. for a C++ file. I suggest you delete this part of the "make" file and rename
  305. the .cpp files to something your compiler recognises.
  306.  
  307. My "make" files for Unix systems are for use with 'gmake' rather than 'make'.
  308. Ordinary 'make' works with them on the Sun but not the Silicon Graphics or HP
  309. machines. 
  310.  
  311. Your source files that access the newmat you will need to #include one or more
  312. of the following files.
  313.  
  314. include.h:
  315.    if you want to access just the compiler options
  316.  
  317. newmat.h:
  318.    to access just the main matrix library (includes include.h)
  319.  
  320. newmatap.h:
  321.    to access the advanced matrix routines such as Cholesky decomposition, QR
  322. triangularisation etc (includes newmat.h)
  323.  
  324. newmatio.h:
  325.    to access the output routines (includes newmat.h) You can use this only
  326. with compilers that support the standard input/output routines including
  327. manipulators. It cannot be used with Zortech or early versions of Gnu.
  328.  
  329. newmatnl.h:
  330.    to access the non-linear optimisation routines (includes newmat.h)
  331.  
  332.  
  333.  
  334. See the section on customising [2.2] to see how to edit include.h for your
  335. environment and the section on compilers [2.3] for any special problems with
  336. the compiler you are using.
  337.  
  338.  
  339.  
  340.  
  341.         2.2  Customising
  342.         ===  ===========
  343.  
  344. The file  include.h  sets a variety of options including several compiler
  345. dependent options. You may need to edit include.h to get the options you
  346. require. If you are using a compiler different from one I have worked with you
  347. may have to set up a new section in  include.h  appropriate for your compiler.
  348.  
  349. Borland, Turbo, Gnu, Microsoft, Watcom and Zortech are recognised
  350. automatically. If none of these are recognised a default set of options is
  351. used. These are fine for AT&T, HPUX and Sun C++. If you using a compiler I
  352. don't know about you may have to write a new set of options.
  353.  
  354. Activate the appropriate statement to make the element type float or double.
  355.  
  356. If you are using the standard style for deleting arrays (AT&T version 2.1 or
  357. later) make sure Version21 is #defined. If you are using the old style, make
  358. sure it is not #defined.
  359.  
  360. There is an option in include.h for selecting whether you use compiler
  361. supported exceptions, simulated exceptions, or disable exceptions. Use the
  362. option for compiler supported exceptions if and only if you have set the
  363. option on your compiler to recognise exceptions. Disabling exceptions
  364. sometimes helps with compilers that are incompatible with my exception
  365. simulation scheme.
  366.  
  367. I suggest you leave the option TEMPS_DESTROYED_QUICKLY activated, even though
  368. the Gnu compiler is the only one I know about that requires it. This stores
  369. the "trees" dsecribing matrix expressions on the heap rather than the stack
  370. and, surprisingly, seems to give better performance. See the discussion in
  371. newmatb.txt for more explanation.
  372.  
  373. Leave the option TEMPS_DESTROYED_QUICKLY_R not activated unless you are using
  374. the Gnu G++ [2.3.3] compiler. This option controls whether the ReturnMatrix
  375. [3.13] construct uses the stack or the heap. The heap version is rather kludgy
  376. and probably should be avoided where possible.
  377.  
  378. The option DO_FREE_CHECK is used for tracking memory leaks and normally should
  379. not be activated.
  380.  
  381. Activate SETUP_C_SUBSCRIPTS if you want to use traditional C style element
  382. access [3.2]. 
  383.  
  384.  
  385.  
  386.  
  387.         2.3  Compiler performance
  388.         ===  ======== ===========
  389.  
  390. I have tested this library on a number of compilers. Here are the levels of
  391. success and any special considerations. In most cases I have chosen code that
  392. works under all the compilers I have access to, but I have had to include some
  393. specific work-arounds for some compilers. For the MsDos versions, I use a
  394. 486dx computer running MsDos 6 or windows NT. The unix versions are on a Sun
  395. Sparc station or a Silicon Graphics or a HP unix workstation. Thanks to
  396. Victoria University and Industrial Research Ltd for access to the Unix
  397. machines.
  398.  
  399. I have set up a block of code for each of the compilers in include.h. Turbo,
  400. Borland, Gnu, Zortech, Microsoft and Watcom are recognised automatically.
  401. There is a default option that works for AT&T, Sun C++ 4.0.1 and HPUX. So you
  402. don't have to make any changes for these compilers. Otherwise you may have to
  403. build your own set of options in include.h.
  404.  
  405.         AT&T                                         2.3.1
  406.         Borland                                      2.3.2
  407.         Gnu G++                                      2.3.3
  408.         HPUX                                         2.3.4
  409.         Microsoft                                    2.3.5
  410.         Sun                                          2.3.6
  411.         Watcom                                       2.3.7
  412.         Zortech                                      2.3.8
  413.  
  414.  
  415.  
  416.  
  417.         2.3.1  AT&T
  418.         =====  ====
  419.  
  420. AT&T C++ 2.1;3.0.1 on a Sun: It works fine with 3.0.1. I haven't been able to
  421. test the latest version of the library on 2.1. The previous version worked
  422. fine. Except aggregates are not supported in 2.1 and setjmp.h generated a
  423. warning message. If you are using "interviews" you may get a conflict with
  424. Catch. Either #undefine Catch or replace Catch with CATCH throughout my
  425. package. In AT&T 2.1 you may get an error when you use an expression for the
  426. single argument when constructing a Vector or DiagonalMatrix or one of the
  427. Triangular Matrices. You need to evaluate the expression separately.
  428.  
  429. You cannot run my non-linear [3.26] package with these compilers, because of
  430. my use of labels.
  431.  
  432.  
  433.  
  434.         2.3.2  Borland
  435.         =====  =======
  436.  
  437. Borland C++ 3.1, 4.5: Recently this has been my main development platform, so
  438. naturally everything works with this compiler. There was a problem with the
  439. library utility in version 2.0 which is now fixed. You will need to use the
  440. large model. If you are not debugging, turn off the options that collect
  441. debugging information. Make sure you don't run Borland's exceptions and my
  442. simulated exceptions at the same time.
  443.  
  444. When running my test program with Borland 4.5 under ms-dos you may run out of
  445. memory. Either compile the test routine to run under "easywin" or use
  446. simulated exceptions rather than the built in exceptions. Under "easywin" the
  447. test program indicates a memory leak. I presume this is partly because of the
  448. way windows organises its heap rather than there being a real problem.
  449.  
  450. However there does seem to be genuine memory problem when you use the built-in
  451. exceptions. Under "easywin" the automatic clean-up of objects by the exception
  452. mechanism does not seem to work. Use my simulated exceptions if this is a
  453. problem.
  454.  
  455.  
  456.  
  457.         2.3.3  Gnu G++
  458.         =====  === ===
  459.  
  460. Gnu G++ 2.3.3, 2.5.8:  These mostly work. You must enable the options
  461. TEMPS_DESTROYED_QUICKLY and TEMPS_DESTROYED_QUICKLY_R. You can't use
  462. expressions like Matrix(X*Y) in the middle of an expression and (Matrix)(X*Y)
  463. is unreliable. If you write a function returning a matrix, you MUST use the
  464. ReturnMatrix [3.13] method described in this documentation. This is because
  465. g++ destroys temporaries occuring in an expression too soon for the two stage
  466. way of evaluating expressions that newmat uses.  Gnu seems to leave some
  467. rubbish on the stack. Possibly this is a printer buffer so it may not be a
  468. bug. You will have problems with versions of Gnu earlier than 2.3.1.
  469.  
  470. Linux: Gnu G++ 2.5.8 seems a little more touchy than regular G++. But
  471. basically the package works.
  472.  
  473. Gnu G++ 2.6.0: Seems OK. There should be better compatibility because version
  474. 2.6 retains temporaries until the end of the statement instead of destroying
  475. them immediately following the first access. I suggest you enable option
  476. TEMPS_DESTROYED_QUICKLY but not TEMPS_DESTROYED_QUICKLY_R.
  477.  
  478.  
  479.  
  480.         2.3.4  HP-UX
  481.         =====  =====
  482.  
  483. HP 9000 series HP-UX. I have tried the library on two versions of HP-UX. (I
  484. don't know the version numbers, the older is a clone of AT&T 3, the newer is
  485. HP's version with exceptions). Both worked after the modifications described
  486. in this section except that I couldn't compile the non-linear [3.26] package
  487. due to my use of labels.
  488.  
  489. With the older version of the compiler I needed to edit the math.h library
  490. file to remove a duplicate definition of abs.
  491.  
  492. With the newer version you can set the +eh option to enable exceptions and
  493. activate the UseExceptions option in include.h. If you are using my make file,
  494. you will need to replace CC with CC +eh where ever CC occurs. I recommend that
  495. you do not do this and either disable exceptions or use my simulated
  496. exceptions. I get core dumps when I use the built-in exceptions and suspect
  497. they are not sufficiently debugged as yet.
  498.  
  499. If you are using my simulated exceptions you may get a mass of error messages
  500. from the linker about __EH_JMPBUF_TEMP. In this case get file setjmp.h (in
  501. directory /usr/include/CC ?) and put extern in front of the line
  502.  
  503.    jmp_buf * __EH_JMPBUF_TEMP;
  504.  
  505. The file setjmp.h is accessed in my file myexcept.h. You may want to change
  506. the #include statement to access your edited copy of setjmp.h.
  507.  
  508.  
  509.  
  510.         2.3.5  Microsoft
  511.         =====  =========
  512.  
  513. Microsoft C++ (7.0, 8.0): Seems to work OK. You must #define
  514. TEMPS_DESTROYED_QUICKLY owing to a bug in version 7 (at least) of MSC. There
  515. are some notes in the file include.h on changes to run under version 7. I
  516. haven't tried the latest version of newmat08 on version 7.
  517.  
  518. Haven't tried visual C++ yet.
  519.  
  520.  
  521.  
  522.  
  523.         2.3.6  Sun
  524.         =====  ===
  525.  
  526. Sun C++ (version 4.0.1): This generally works fine. However, I suspect that
  527. there is a problem with my non-linear [3.26] package, even though the program
  528. appears to run correctly, probably because of my use of labels. When I set
  529. DO_FREE_CHECK, I detect non-existent objects being deleted and the program
  530. fails if I use simulated exceptions.
  531.  
  532.  
  533.  
  534.         2.3.7  Watcom
  535.         =====  ======
  536.  
  537. Watcom C++ (version 10): basically this works fine. Don't try to run Watcom's
  538. exceptions and my simulated exceptions at the same time.
  539.  
  540. There does seem to be a problem with expressions such as
  541.  
  542.    X = Matrix(A+B)+C;
  543.  
  544. Occasionally the temporary object created by Matrix(A+B) is destroyed twice.
  545. In most cases this does not seem to cause a problem. However, I think one
  546. should avoid code such as this - in fact, there is generally not much point to
  547. such code. Alternatively use my simulated exceptions as the problem seems to
  548. occur only with the built in exceptions enabled. 
  549.  
  550.  
  551.  
  552.         2.3.8  Zortech
  553.         =====  =======
  554.  
  555. Zortech C++ 3.04: "const" doesn't work correctly with this compiler, so the
  556. package skips all of the statements Zortech can't handle. Zortech leaves
  557. rubbish on the heap. I don't know whether this is my programming error or a
  558. Zortech error or additional printer buffers. Deactivate the option for version
  559. 2.1 in include.h. Does not support IO manipulators. Otherwise the package
  560. mostly works, but not completely. Best don't #define TEMPS_DESTROYED_QUICKLY.
  561. Exceptions and the nric interface don't work. I think some of the problems are
  562. because Zortech doesn't handle conversions correctly, particularly automatic
  563. conversions. But, also newmat is just too big for my version of Zortech.
  564. Zortech runs much more slowly than Borland and Microsoft. Use the large model
  565. and compile as much as possible with optimisation on to save space. You won't
  566. be able to get the whole test program to work. Zortech doesn't have
  567. io-manipulators so you can't compile the example.
  568.  
  569. I haven't tried the Symantec successors to Zortech.
  570.  
  571.  
  572.  
  573.  
  574.  
  575.         2.4  Updating newmat08
  576.         ===  ======== ========
  577.  
  578.         Updating from previous 08 betas               2.4.1
  579.         Updating from previous versions               2.4.2
  580.  
  581.  
  582.         2.4.1  Updating from previous 08 betas
  583.         =====  ======== ==== ======== == =====
  584.  
  585.  
  586. If you were using the non-linear optimisation routine in an previous beta,
  587. note that rowvectors and columnvectors have been swapped in this version of
  588. newmatnl. You now derive from prototype function classes rather than the
  589. solution and least squares classes. Simple examples are included with the
  590. library.
  591.  
  592. This version includes concatenation operators, elementwise products for
  593. matrices and GenericMatrices. See the sections on binary operators [3.6] and
  594. unspecified types [3.16].
  595.  
  596. There is now no need to explicitly set the AT&T option in include.h.
  597.  
  598. I have reorganised the make files for AT&T, Gnu, Microsoft and Watcom. See the
  599. files [6] section.
  600.  
  601.  
  602.         2.4.2  Updating form previous versions
  603.         =====  ======== ==== ======== ========
  604.  
  605. This is a minor upgrade on newmat07 to correct errors (one serious) and
  606. improve compatibility with various compilers. You should upgrade.
  607.  
  608. *  .cxx files are now .cpp files. Some versions of won't accept .cpp. The
  609. "make" files for Gnu and AT&T link the .cpp files to .cxx files before
  610. compilation and delete the links after compilation.
  611.  
  612. *  An option [2.2] in include.h allows you to use compiler supported
  613. exceptions, simulated exceptions or disable exceptions. Edit the file
  614. include.h to select one of these three options. Don't simulate exceptions if
  615. you have set your compiler's option to implement exceptions.
  616.  
  617. *  New QR decomposition [3.18] functions.
  618.  
  619. *  A non-linear least squares [3.26] class.
  620.  
  621. *  No need to explicitly set the AT&T option in include.h.
  622.  
  623. *  Concatenation and elementwise multiplication [3.6].
  624.  
  625. *  A new GenericMatrix [3.16] class.
  626.  
  627. *  Sum [3.8] function.
  628.  
  629. *  Some of the make [6] files reorganised. 
  630.  
  631.  
  632. If you are upgrading from newmat06 note the following:
  633.  
  634. *  If you are using << to load a Real into a submatrix change this to =.
  635.  
  636.  
  637. If you are upgrading from newmat03 or newmat04 note the following
  638.  
  639. *  .hxx files are now .h files
  640.  
  641. *  real changed to Real
  642.  
  643. *  BOOL changed to Boolean
  644.  
  645. *  CopyToMatrix changed to AsMatrix, etc
  646.  
  647. *  real(A) changed to A.AsScalar()
  648.  
  649.  
  650. The current version is quite a bit longer that newmat04, so if you are almost
  651. out of space with newmat04, don't throw newmat04 away until you have checked
  652. your program will work under this version.
  653.  
  654. See the change history [1.7] for other changes.
  655.  
  656.  
  657.         2.5  Example
  658.         ===  =======
  659.  
  660. An example is given in  example.cpp.  This gives a simple linear regression
  661. example using four different algorithms. The correct output is given in
  662. example.txt. The program carries out a rough check that no memory is left
  663. allocated on the heap when it terminates. See the section on testing [2.6] for
  664. a comment on the reliability of this check and the use of the DO_FREE_CHECK
  665. option.
  666.  
  667. I include a variety of make files. Use a command like
  668.  
  669.    gmake example -f gnu.mak               (Gnu G++)
  670.    gmake example -f cc.mak                (AT&T, HPUX, Sun)
  671.    nmake example -f ms_nt.mak             (Microsoft C++ 8.0)
  672.    make -f ex_b.mak                       (Borland C++ 3.1)
  673.    make -f ex_bc45.mak                    (Borland C++ 4.5)
  674.    wmake example.exe -f watcom.mak        (Watcom C++ 10A)
  675.    wmake example.exe -f watco_nt.mak      (Watcom C++ 10A)
  676.  
  677. The Borland files were derived from the project file and you will have to edit
  678. these to suit your environment. The file ex_bc45.mak is for making a windows
  679. NT executable program. The Microsoft file is for the version of C++ that came
  680. with the Windows NT 3.1 development kit. The second Watcom file is for making
  681. a Windows NT executable.
  682.  
  683.  ------------------------------------------------------------------------------
  684. This example uses io manipulators. It will not work with a compiler that does
  685. not support the standard io manipulators.
  686.  ------------------------------------------------------------------------------
  687.  
  688.  
  689.  
  690.         2.6  Testing
  691.         ===  =======
  692.  
  693. The library package contains a comprehensive test program in the form of a
  694. series of files with names of the form tmt?.cxx. The files consist of a large
  695. number of matrix formulae all of which evaluate to zero (except the first one
  696. which is used to check that we are detecting non-zero matrices). The printout
  697. should state that it has found just one non-zero matrix.
  698.  
  699. Various versions of the make file (extension .mak) are included with the
  700. package. See the section on files [6].
  701.  
  702. The program also allocates and deletes a large block and small block of memory
  703. before it starts the main testing and then at the end of the test. It then
  704. checks that the blocks of memory were allocated in the same place. If not then
  705. one suspects that there has been a memory leak. i.e. a piece of memory has
  706. been allocated and not deleted.
  707.  
  708. This is not completely foolproof. Programs may allocate extra print buffers
  709. while the program is running. I have tried to overcome this by doing a print
  710. before I allocate the first memory block. Programs may allocate memory for
  711. different sized items in different places, or might not allocate items
  712. consecutively. Or they might mix the items with memory blocks from other
  713. programs. Nevertheless, I seem to get consistent answers from many of the
  714. compilers I am working with, so I think this is a worthwhile test.
  715.  
  716. If the DO_FREE_CHECK [2.2] option in include.h is activated, the program
  717. checks that each 'new' is balanced with exactly one 'delete'. This provides a
  718. more definitive test of no memory leaks. There are additional statements in
  719. myexcept.cpp which can be activated to print out details of the memory being
  720. allocated and released.
  721.  
  722. Several of the files have a line defining 'REPORT' that can be activated
  723. (deactivate the dummy version). This gives a printout of the number of times
  724. each of the 'REPORT' statements in the file is accessed. Use a grep with line
  725. numbers to locate the lines on which 'REPORT' occurs and compare these with
  726. the lines that the printout shows were actually accessed.
  727.  
  728.  
  729.         3  Reference manual
  730.         =  ========= ======
  731.  
  732.         Constructors                                 3.1
  733.         Accessing elements                           3.2
  734.         Assignment and copying                       3.3
  735.         Entering values                              3.4
  736.         Unary operations                             3.5
  737.         Binary operations                            3.6
  738.         Matrix and scalar ops                        3.7
  739.         Scalar functions                             3.8
  740.         Submatrices                                  3.9 
  741.         Change dimension                             3.10 
  742.         Change type                                  3.11 
  743.         Multiple matrix solve                        3.12 
  744.         Memory management                            3.13 
  745.         Efficiency                                   3.14 
  746.         Output                                       3.15 
  747.         Accessing unspecified type                   3.16 
  748.         Cholesky decomposition                       3.17 
  749.         QR decomposition                             3.18 
  750.         Singular value decomposition                 3.19
  751.         Eigenvalue decomposition                     3.20 
  752.         Sorting                                      3.21
  753.         Fast Fourier transform                       3.22 
  754.         Numerical recipes in C                       3.23
  755.         Exceptions                                   3.24 
  756.         Cleanup following exception                  3.25
  757.         Non-linear applications                      3.26 
  758.  
  759.  
  760.         3.1  Constructors
  761.         ===  ============
  762.  
  763. To construct an m x n matrix, 'A', (m and n are integers) use
  764.  
  765.     Matrix A(m,n);
  766.  
  767. The UpperTriangularMatrix, LowerTriangularMatrix, SymmetricMatrix and
  768. DiagonalMatrix types are square. To construct an n x n matrix use, for example
  769.  
  770.     UpperTriangularMatrix UT(n);
  771.     LowerTriangularMatrix LT(n);
  772.     SymmetricMatrix S(n);
  773.     DiagonalMatrix D(n);
  774.  
  775. Band matrices need to include bandwidth information in their constructors.
  776.  
  777.     BandMatrix BM(n, lower, upper);
  778.     UpperBandMatrix UB(n, upper);
  779.     LowerBandMatrix LB(n, lower);
  780.     SymmetrixBandMatrix SB(n, lower);
  781.  
  782. The integers upper and lower are the number of non-zero diagonals above and
  783. below the diagonal (excluding the diagonal) respectively.
  784.  
  785. The RowVector and ColumnVector types take just one argument in their
  786. constructors:
  787.  
  788.     RowVector RV(n);
  789.     ColumnVector CV(n);
  790.  
  791. You can also construct vectors and matrices without specifying the dimension.
  792. For example
  793.  
  794.     Matrix A;
  795.  
  796. In this case the dimension must be set by an assignment statement [3.3] or a
  797. re-dimension statement [3.10].
  798.  
  799. You can also use a constructor to set a matrix equal to another matrix or
  800. matrix expression.
  801.  
  802.     Matrix A = UT;
  803.     Matrix A = UT * LT;
  804.  
  805. Only conversions that don't lose information are supported - eg you cannot
  806. convert an upper triangular matrix into a diagonal matrix using =.
  807.  
  808.  
  809.  
  810.         3.2  Accessing elements
  811.         ===  ========= ========
  812.  
  813. Elements are accessed by expressions of the form 'A(i,j)' where i and j run
  814. from 1 to the appropriate dimension. Access elements of vectors with just one
  815. argument. Diagonal matrices can accept one or two subscripts.
  816.  
  817. This is different from the earliest version of the package in which the
  818. subscripts ran from 0 to one less than the appropriate dimension. Use
  819. 'A.element(i,j)' if you want this earlier convention.
  820.  
  821. 'A(i,j)' and 'A.element(i,j)' can appear on either side of an = sign.
  822.  
  823. If you activate the '#define SETUP_C_SUBSCRIPTS' in 'include.h' you can also
  824. access elements using the tradition C style notation. That is 'A[i][j]' for
  825. matrices (except diagonal) and 'V[i]' for vectors and diagonal matrices. The
  826. subscripts start at zero (ie like element) and there is no range checking.
  827. Because of the possibility of confusing 'V(i)' and 'V[i]', I suggest you do
  828. not activate this option unless you really want to use it.
  829.  
  830.  
  831.         3.3  Assignment and copying
  832.         ===  ========== === =======
  833.  
  834. The operator = is used for copying matrices, converting matrices, or
  835. evaluating expressions. For example
  836.  
  837.     A = B;  A = L;  A = L * U;
  838.  
  839. Only conversions that don't lose information are supported. The dimensions of
  840. the matrix on the left hand side are adjusted to those of the matrix or
  841. expression on the right hand side. Elements on the right hand side which are
  842. not present on the left hand side are set to zero.
  843.  
  844. The operator << can be used in place of = where it is permissible for
  845. information to be lost.
  846.  
  847. For example
  848.  
  849.     SymmetricMatrix S; Matrix A;
  850.     ......
  851.     S << A.t() * A;
  852.  
  853. is acceptable whereas
  854.  
  855.     S = A.t() * A;                            // error
  856.  
  857. will cause a runtime error since the package does not (yet?) recognise
  858. 'A.t()*A' as symmetric.
  859.  
  860. Note that you can not use << with constructors. For example
  861.  
  862.     SymmetricMatrix S << A.t() * A;           // error
  863.  
  864. does not work.
  865.  
  866. Also note that << cannot be used to load values from a full matrix into a band
  867. matrix, since it will be unable to determine the bandwidth of the band matrix.
  868.  
  869. A third copy routine is used in a similar role to =. Use
  870.  
  871.     A.Inject(D);
  872.  
  873. to copy the elements of 'D' to the corresponding elements of 'A' but leave the
  874. elements of 'A' unchanged if there is no corresponding element of 'D' (the =
  875. operator would set them to 0). This is useful, for example, for setting the
  876. diagonal elements of a matrix without disturbing the rest of the matrix.
  877. Unlike = and <<, Inject does not reset the dimensions of 'A', which must match
  878. those of 'D'. Inject does not test for no loss of information.
  879.  
  880. You cannot replace 'D' by a matrix expression. The effect of 'Inject(D)'
  881. depends on the type of 'D'. If 'D' is an expression it might not be obvious to
  882. the user what type it would have. So I thought it best to disallow
  883. expressions.
  884.  
  885. Inject can be used for loading values from a regular matrix into a band
  886. matrix. (Don't forget to zero any elements of the left hand side that will not
  887. be set by the loading operation).
  888.  
  889. Both << and Inject can be used with submatrix expressions on the left hand
  890. side. See the section on submatrices [3.9].
  891.  
  892. To set the elements of a matrix to a scalar use operator =
  893.  
  894.     Real r; Matrix A(m,n);
  895.     ......
  896.     Matrix A(m,n); A = r;
  897.  
  898.  
  899.  
  900.  
  901.         3.4  Entering values
  902.         ===  ======== ======
  903.  
  904. You can load the elements of a matrix from an array:
  905.  
  906.     Matrix A(3,2);
  907.     Real a[] = { 11,12,21,22,31,33 };
  908.     A << a;
  909.  
  910. This construction does not check that the numbers of elements match correctly.
  911. This version of << can be used with submatrices on the left hand side. It is
  912. not defined for band matrices.
  913.  
  914. Alternatively you can enter short lists using a sequence of numbers separated
  915. by << .
  916.  
  917.     Matrix A(3,2);
  918.     A << 11 << 12
  919.       << 21 << 22
  920.       << 31 << 32;
  921.  
  922. This does check for the correct total number of entries, although the message
  923. for there being insufficient numbers in the list may be delayed until the end
  924. of the block or the next use of this construction. This does not work for band
  925. matrices or submatrices, or for long lists. Also try to restrict its use to
  926. numbers. You can include expressions, but these must not call a function which
  927. includes the same construction.
  928.  
  929.  
  930.  
  931.         3.5  Unary operators
  932.         ===  ===== =========
  933.  
  934. The package supports unary operations
  935.  
  936.     X = -A      // change sign of elements
  937.     X = A.t()   // transpose
  938.     X = A.i()   // inverse (of square matrix A)
  939.  
  940.  
  941.  
  942.  
  943.         3.6  Binary operators
  944.         ===  ====== =========
  945.  
  946. The package supports binary operations
  947.  
  948.     X = A + B      // matrix addition
  949.     X = A - B      // matrix subtraction
  950.     X = A * B      // matrix multiplication
  951.     X = A.i() * B  // equation solve (square matrix A)
  952.     X = A | B      // concatenate horizontally (concatenate the rows)
  953.     X = A & B      // concatenate vertically (concatenate the columns)
  954.     X = SP(A, B)   // elementwise product of A and B (Schur product)
  955.  
  956.  
  957. Notes:
  958.  
  959. *  If you are doing repeated multiplication. For example 'A*B*C', use brackets
  960. to force the order of evaluation to minimize the number of operations. If 'C'
  961. is a column vector and 'A' is not a vector, then it will usually reduce the
  962. number of operations to use 'A*(B*C)'.
  963.  
  964. *  In the equation solve example case the inverse is not explicitly
  965. calculated. An LU decomposition of 'A' is performed and this is applied to
  966. 'B'. This is more efficient than calculating the inverse and then multiplying.
  967. See also multiple matrix solving [3.12].
  968.  
  969. *  The package does not (yet?) recognise 'B*A.i()' as an equation solve and
  970. the inverse of 'A' would be calculated. It is probably better to use
  971. '(A.t().i()*B.t()).t()'.
  972.  
  973. *  Horizontal or vertical concatenation returns a result of type Matrix,
  974. RowVector or ColumnVector.
  975.  
  976. *  If 'A' is m x p, 'B' is m x q, then 'A | B' is m x (p+q) with the k-th row
  977. being the elements of the k-th row of 'A' followed by the elements of the k-th
  978. row of 'B'.
  979.  
  980. *  If 'A' is p x n, 'B' is q x n, then 'A & B' is (p+q) x n with the k-th
  981. column being the elements of the k-th column of 'A' followed by the elements
  982. of the k-th column of 'B'.
  983.  
  984. *  For complicated concatenations of matrices, consider instead using
  985. submatrices [3.9].
  986.  
  987.  
  988.  
  989.  
  990.         3.7  Matrix and scalar
  991.         ===  ====== === ======
  992.  
  993. The following expression multiplies the elements of a matrix 'A' by a scalar
  994. f: 'A * f;' Likewise one can divide the elements of a matrix 'A' by a scalar
  995. f:' A / f;'
  996.  
  997. The expressions  'A + f' and 'A - f' add or subtract a rectangular matrix of
  998. the same dimension as 'A' with elements equal to 'f' to or from the matrix
  999. 'A'.
  1000.  
  1001. In each case the matrix must be the first term in the expression. Expressions
  1002. such  'f + A'  or  'f * A'  are not recognised (yet?).
  1003.  
  1004.  
  1005.  
  1006.  
  1007.         3.8  Scalar functions of a matrix
  1008.         ===  ====== ========= == = ======
  1009.  
  1010.  
  1011.     int m = A.Nrows();                    // number of rows
  1012.     int n = A.Ncols();                    // number of columns
  1013.     Real ssq = A.SumSquare();             // sum of squares of elements
  1014.     Real sav = A.SumAbsoluteValue();      // sum of absolute values
  1015.     Real s = A.Sum();                     // sum of values
  1016.     Real mav = A.MaximumAbsoluteValue();  // maximum of absolute values
  1017.     Real norm = A.Norm1();                // maximum of sum of absolute
  1018.                                              values of elements of a column
  1019.     Real norm = A.NormInfinity();         // maximum of sum of absolute
  1020.                                              values of elements of a row
  1021.     Real t = A.Trace();                   // trace
  1022.     LogandSign ld = A.LogDeterminant();   // log of determinant
  1023.     Boolean z = A.IsZero();               // test all elements zero
  1024.     MatrixType mt = A.Type();             // type of matrix
  1025.     Real* s = Store();                    // pointer to array of elements
  1026.     int l = Storage();                    // length of array of elements
  1027.  
  1028. 'A.LogDeterminant()' returns a value of type LogandSign. If ld is of type
  1029. LogAndSign  use
  1030.  
  1031.     ld.Value()    to get the value of the determinant
  1032.     ld.Sign()     to get the sign of the determinant (values 1, 0, -1)
  1033.     ld.LogValue() to get the log of the absolute value.
  1034.  
  1035. 'A.IsZero()' returns Boolean value TRUE if the matrix 'A' has all elements
  1036. equal to 0.0.
  1037.  
  1038. 'MatrixType mt = A.Type()' returns the type of a matrix. Use '(char*)mt' to
  1039. get a string  (UT, LT, Rect, Sym, Diag, Band, UB, LB, Crout, BndLU) showing
  1040. the type (Vector types are returned as Rect).
  1041.  
  1042. The versions Sum(A), SumSquare(A), SumAbsoluteValue(A),
  1043. MaximumAbsoluteValue(A), Trace(A), LogDeterminant(A), Norm1(A),
  1044. NormInfinity(A)  can be used in place of A.Sum(), A.SumSquare(),
  1045. A.SumAbsoluteValue(), A.MaximumAbsoluteValue(), A.Trace(), A.LogDeterminant(),
  1046. A.Norm1(), A.NormInfinity().
  1047.  
  1048.  
  1049.  
  1050.         3.9  Submatrices
  1051.         ===  ===========
  1052.  
  1053.  
  1054.     A.SubMatrix(fr,lr,fc,lc)
  1055.  
  1056. This selects a submatrix from 'A'. The arguments  fr,lr,fc,lc are the first
  1057. row, last row, first column, last column of the submatrix with the numbering
  1058. beginning at 1. This may be used in any matrix expression or on the left hand
  1059. side of =, << or Inject. Inject does not check no information loss. You can
  1060. also use the construction
  1061.  
  1062.     Real c; .... A.SubMatrix(fr,lr,fc,lc) = c;
  1063.  
  1064. to set a submatrix equal to a constant.
  1065.  
  1066. The follwing are variants of SubMatrix:
  1067.  
  1068.     A.SymSubMatrix(f,l)             //   This assumes fr=fc and lr=lc.
  1069.     A.Rows(f,l)                     //   select rows
  1070.     A.Row(f)                        //   select single row
  1071.     A.Columns(f,l)                  //   select columns
  1072.     A.Column(f)                     //   select single column
  1073.  
  1074. In each case f and l mean the first and last row or column to be selected
  1075. (starting at 1).
  1076.  
  1077. If SubMatrix or its variant occurs on the right hand side of an = or << or
  1078. within an expression its type is as follows
  1079.  
  1080.     A.Submatrix(fr,lr,fc,lc):           If A is RowVector or
  1081.                                         ColumnVector then same type
  1082.                                         otherwise type Matrix
  1083.     A.SymSubMatrix(f,l):                Same type as A
  1084.     A.Rows(f,l):                        Type Matrix
  1085.     A.Row(f):                           Type RowVector
  1086.     A.Columns(f,l):                     Type Matrix
  1087.     A.Column(f):                        Type ColumnVector
  1088.  
  1089. If SubMatrix or its variant appears on the left hand side of  = or << , think
  1090. of its type being Matrix. Thus 'L.Row(1)' where 'L' is LowerTriangularMatrix
  1091. expects 'L.Ncols()' elements even though it will use only one of them. If you
  1092. are using = the program will check for no loss of data.
  1093.  
  1094. If you are are using the submatrix facility to build a matrix from a small
  1095. number of components, consider instead using the concatenation operators
  1096. [3.6].
  1097.  
  1098.  
  1099.  
  1100.         3.10  Change dimensions
  1101.         ====  ====== ==========
  1102.  
  1103. The following operations change the dimensions of a matrix. The values of the
  1104. elements are lost.
  1105.  
  1106.     A.ReDimension(nrows,ncols);     // for type Matrix or nricMatrix
  1107.     A.ReDimension(n);               // for all other types, except Band
  1108.     A.ReDimension(n,lower,upper);   // for BandMatrix
  1109.     A.ReDimension(n,lower);         // for LowerBandMatrix
  1110.     A.ReDimension(n,upper);         // for UpperBandMatrix
  1111.     A.ReDimension(n,lower);         // for SymmetricBandMatrix
  1112.  
  1113. Use   'A.CleanUp()'  to set the dimensions of 'A' to zero and release all the
  1114. heap memory.
  1115.  
  1116. Remember that 'ReDimension' destroys values. If you want to 'ReDimension', but
  1117. keep the values in the bit that is left use something like
  1118.  
  1119.    ColumnVector V(100);
  1120.    ...                            // load values
  1121.    V = V.Rows(1,50);              // to get first 50 values.
  1122.  
  1123. If you want to extend a matrix or vector use something like
  1124.  
  1125.    ColumnVector V(50);
  1126.    ...                            // load values
  1127.    { V.Release(); ColumnVector X=V; V.ReDimension(100); V.Rows(1,50)=X; }
  1128.                                   // V now length 100
  1129.  
  1130.  
  1131.  
  1132.  
  1133.         3.11  Change type
  1134.         ====  ====== ====
  1135.  
  1136. The following functions interpret the elements of a matrix (stored row by row)
  1137. to be a vector or matrix of a different type. Actual copying is usually
  1138. avoided where these occur as part of a more complicated expression.
  1139.  
  1140.     A.AsRow()
  1141.     A.AsColumn()
  1142.     A.AsDiagonal()
  1143.     A.AsMatrix(nrows,ncols)
  1144.     A.AsScalar()
  1145.  
  1146. The expression 'A.AsScalar()' is used to convert a 1 x 1 matrix to a scalar.
  1147.  
  1148.  
  1149.  
  1150.         3.12  Multiple matrix solve
  1151.         ====  ======== ====== =====
  1152.  
  1153. If 'A' is a square or symmetric matrix use
  1154.  
  1155.     CroutMatrix X = A;                // carries out LU decomposition
  1156.     Matrix AP = X.i()*P; Matrix AQ = X.i()*Q;
  1157.     LogAndSign ld = X.LogDeterminant();
  1158.  
  1159. rather than
  1160.  
  1161.     Matrix AP = A.i()*P; Matrix AQ = A.i()*Q;
  1162.     LogAndSign ld = A.LogDeterminant();
  1163.  
  1164. since each operation will repeat the LU decomposition.
  1165.  
  1166. If 'A' is a BandMatrix or a SymmetricBandMatrix begin with
  1167.  
  1168.     BandLUMatrix X = A;               // carries out LU decomposition
  1169.  
  1170. A CroutMatrix or a BandLUMatrix can't be manipulated or copied. Use references
  1171. as an alternative to copying.
  1172.  
  1173. Alternatively use
  1174.  
  1175.     LinearEquationSolver X = A;
  1176.  
  1177. This will choose the most appropiate decomposition of 'A'. That is, the band
  1178. form if 'A' is banded; the Crout decomposition if 'A' is square or symmetric
  1179. and no decomposition if 'A' is triangular or diagonal. If you want to use the
  1180. LinearEquationSolver '#include newmatap.h'.
  1181.  
  1182.  
  1183.  
  1184.         3.13  Memory management
  1185.         ====  ====== ==========
  1186.  
  1187. The package does not support delayed copy. Several strategies are required to
  1188. prevent unnecessary matrix copies.
  1189.  
  1190. Where a matrix is called as a function argument use a constant reference. For
  1191. example
  1192.  
  1193.     YourFunction(const Matrix& A)
  1194.  
  1195. rather than
  1196.  
  1197.     YourFunction(Matrix A)
  1198.  
  1199.  
  1200. Skip the rest of this section on your first reading.
  1201.  ------------------------------------------------------------------------------
  1202. Gnu g++ (< 2.6) users please read on; if you are returning matrix values from
  1203. a function, then you must use the ReturnMatrix construct.     
  1204.  ------------------------------------------------------------------------------
  1205.  
  1206. A second place where it is desirable to avoid unnecessary copies is when a
  1207. function is returning a matrix. Matrices can be returned from a function with
  1208. the return command as you would expect. However these may incur one and
  1209. possibly two copyings of the matrix. To avoid this use the following
  1210. instructions.
  1211.  
  1212. Make your function of type  ReturnMatrix . Then precede the return statement
  1213. with a Release statement (or a ReleaseAndDelete statement if the matrix was
  1214. created with new). For example
  1215.  
  1216.  
  1217.     ReturnMatrix MakeAMatrix()
  1218.     {
  1219.        Matrix A;
  1220.        ......
  1221.        A.Release(); return A;
  1222.     }
  1223.  
  1224. or
  1225.  
  1226.     ReturnMatrix MakeAMatrix()
  1227.     {
  1228.        Matrix* m = new Matrix;
  1229.        ......
  1230.        m->ReleaseAndDelete(); return *m;
  1231.     }
  1232.  
  1233. If your compiler objects to this code, replace the return statements with
  1234.  
  1235.     return A.ForReturn();
  1236.  
  1237. or
  1238.  
  1239.     return m->ForReturn();
  1240.  
  1241.  
  1242. If you are using AT&T C++ you may wish to replace  'return A;' by return
  1243. '(ReturnMatrix)A;'  to avoid a warning message; but this will give a runtime
  1244. error with Gnu. (You can't please everyone.)
  1245.  ------------------------------------------------------------------------------
  1246. Do not forget to make the function of type ReturnMatrix; otherwise you may get
  1247. incomprehensible run-time errors.                       
  1248.  ------------------------------------------------------------------------------
  1249. You can also use '.Release()' or '->ReleaseAndDelete()' to allow a matrix
  1250. expression to recycle space. Suppose you call
  1251.  
  1252.     A.Release();
  1253.  
  1254. just before 'A' is used just once in an expression. Then the memory used by
  1255. 'A' is either returned to the system or reused in the expression. In either
  1256. case, 'A''s memory is destroyed. This procedure can be used to improve
  1257. efficiency and reduce the use of memory.
  1258.  
  1259. Use '->ReleaseAndDelete' for matrices created by new if you want to completely
  1260. delete the matrix after it is accessed.
  1261.  
  1262.  
  1263.  
  1264.         3.14  Efficiency
  1265.         ====  ==========
  1266.  
  1267. The package tends to be not very efficient for dealing with matrices with
  1268. short rows. This is because some administration is required for accessing rows
  1269. for a variety of types of matrices. To reduce the administration a special
  1270. multiply routine is used for rectangular matrices in place of the generic one.
  1271. Where operations can be done without reference to the individual rows (such as
  1272. adding matrices of the same type) appropriate routines are used.
  1273.  
  1274. When you are using small matrices (say smaller than 10 x 10) you may find it
  1275. faster to use rectangular matrices rather than the triangular or symmetric
  1276. ones.
  1277.  
  1278.  
  1279.  
  1280.         3.15  Output
  1281.         ====  ======
  1282.  
  1283. To print a matrix use an expression like
  1284.  
  1285.     Matrix A;
  1286.     ......
  1287.     cout << setw(10) << setprecision(5) << A;
  1288.  
  1289. This will work only with systems that support the AT&T input/output routines
  1290. including manipulators. You need to #include the file newmat9.h.
  1291.  
  1292. The present version of this routine is useful only for matrices small enough
  1293. to fit within a page or screen width.
  1294.  
  1295. To print several vectors or matrices in columns use a concatenation operator
  1296. [3.6]:
  1297.  
  1298.    Matrix A, B;
  1299.    .....
  1300.    cout << setw(10) << setprecision(5) << (A | B);
  1301.  
  1302.  
  1303.  
  1304.  
  1305.         3.16  Unspecified type
  1306.         ====  =========== ====
  1307.  
  1308. Skip this section on your first reading.
  1309.  
  1310. If you want to work with a matrix of unknown type, say in a function. You can
  1311. construct a matrix of type 'GenericMatrix'. Eg
  1312.  
  1313.    Matrix A;
  1314.    .....                                  // put some values in A
  1315.    GenericMatrix GM = A;
  1316.  
  1317. A GenericMatrix matrix can be used anywhere where a matrix expression can be
  1318. used and also on the left hand side of an '='. You can pass any type of matrix
  1319. (excluding the Crout and BandLUMatrix types) to a 'const GenericMatrix&'
  1320. argument in a function. However most scalar functions including Nrows(),
  1321. Ncols(), Type() and element access do not work with it. Nor does the
  1322. ReturnMatrix construct. See also the paragraph on LinearEquationSolver [3.12].
  1323.  
  1324. An alternative and less flexible approach is to use Basematrix or
  1325. GeneralMatrix.
  1326.  
  1327. Suppose you wish to write a function which accesses a matrix of unknown type
  1328. including expressions (eg 'A*B'). Then use a layout similar to the following:
  1329.  
  1330.    void YourFunction(BaseMatrix& X)
  1331.    {
  1332.       GeneralMatrix* gm = X.Evaluate();   // evaluate an expression
  1333.                                           // if necessary
  1334.       ........                            // operations on *gm
  1335.       gm->tDelete();                      // delete *gm if a temporary
  1336.    }
  1337.  
  1338. See, as an example, the definitions of 'operator<<' in newmat9.cxx.
  1339.  
  1340. Under certain circumstances; particularly where 'X' is to be used just once in
  1341. an expression you can leave out the 'Evaluate()' statement and the
  1342. corresponding 'tDelete()'. Just use 'X' in the expression.
  1343.  
  1344. If you know YourFunction will never have to handle a formula as its argument
  1345. you could also use
  1346.  
  1347.    void YourFunction(const GeneralMatrix& X)
  1348.    {
  1349.       ........                            // operations on X
  1350.    }
  1351.  
  1352. Do not try to construct a GeneralMatrix or BaseMatrix.
  1353.  
  1354.  
  1355.  
  1356.         3.17  Cholesky decomposition
  1357.         ====  ======== =============
  1358.  
  1359. Suppose S is symmetric and positive definite. Then there exists a unique lower
  1360. triangular matrix L such that L * L.t() = S. To calculate this use
  1361.  
  1362.     SymmetricMatrix S;
  1363.     ......
  1364.     LowerTriangularMatrix L = Cholesky(S);
  1365.  
  1366. If S is a symmetric band matrix then L is a band matrix and an alternative
  1367. procedure is provied for carrying out the decomposition:
  1368.  
  1369.     SymmetricBandMatrix S;
  1370.     ......
  1371.     LowerBandMatrix L = Cholesky(S);
  1372.  
  1373.  
  1374.  
  1375.  
  1376.         3.18  QR decomposition
  1377.         ====  == =============
  1378.  
  1379. This is a variant on the usual QR transformation.
  1380.  
  1381. Start with matrix
  1382.  
  1383.        / 0    0 \      s
  1384.        \ X    Y /      n
  1385.  
  1386.          s    t
  1387.  
  1388. Our version of the QR decomposition multiplies this matrix by an orthogonal
  1389. matrix Q to get
  1390.  
  1391.        / U    M \      s
  1392.        \ 0    Z /      n
  1393.  
  1394.          s    t
  1395.  
  1396. where 'U' is upper triangular (the R of the QR transform).
  1397.  
  1398. This is good for solving least squares problems: choose b (matrix or row
  1399. vector) to minimize the sum of the squares of the elements of
  1400.  
  1401.          Y - X*b
  1402.  
  1403. Then choose 'b = U.i()*M;' The residuals 'Y - X*b' are in 'Z'.
  1404.  
  1405. This is the usual QR transformation applied to the matrix 'X' with the square
  1406. zero matrix attached concatenated on top of it. It gives the same triangular
  1407. matrix as the QR transform applied directly to 'X' and generally seems to work
  1408. in the same way as the usual QR transform. However it fits into the matrix
  1409. package better and also gives us the residuals directly. It turns out to be
  1410. essentially a modified Gram-Schmidt decomposition.
  1411.  
  1412. Two routines are provided:
  1413.  
  1414.     QRZ(X, U);
  1415.  
  1416. replaces 'X' by orthogonal columns and forms 'U'.
  1417.  
  1418.     QRZ(X, Y, M);
  1419.  
  1420. uses 'X' from the first routine, replaces 'Y' by 'Z' and forms 'M'.
  1421.  
  1422. The are also two routines 'QRZT(X, L)' and 'QRZT(X, Y, M)' which do the same
  1423. decomposition on the transposes of all these matrices. QRZT replaces the
  1424. routines HHDecompose in earlier versions of newmat. HHDecompose is still
  1425. defined but just calls QRZT.
  1426.  
  1427.  
  1428.  
  1429.         3.19  Singular value decomposition
  1430.         ====  ======== ===== =============
  1431.  
  1432. The singular value decomposition of an m x n matrix 'A' (where m >= n) is a
  1433. decomposition
  1434.  
  1435.     A  = U * D * V.t()
  1436.  
  1437. where 'U' is m x n with  'U.t() * U'  equalling the identity, 'D' is an n x n
  1438. diagonal matrix and 'V' is an n x n orthogonal matrix.
  1439.  
  1440. Singular value decompositions are useful for understanding the structure of
  1441. ill-conditioned matrices, solving least squares problems, and for finding the
  1442. eigenvalues of 'A.t() * A'.
  1443.  
  1444. To calculate the singular value decomposition of 'A' (with m >= n) use one of
  1445.  
  1446.     SVD(A, D, U, V);                  // U (= A is OK)
  1447.     SVD(A, D);
  1448.     SVD(A, D, U);                     // U (= A is OK)
  1449.     SVD(A, D, U, FALSE);              // U (can = A) for workspace only
  1450.     SVD(A, D, U, V, FALSE);           // U (can = A) for workspace only
  1451.  
  1452. The values of 'A' are not changed unless 'A' is also inserted as the third
  1453. argument.
  1454.  
  1455.  
  1456.  
  1457.         3.20  Eigenvalue decomposition
  1458.         ====  ========== =============
  1459.  
  1460. An eigenvalue decomposition of a symmetric matrix 'A' is a decomposition
  1461.  
  1462.     A  = V * D * V.t()
  1463.  
  1464. where 'V' is an orthogonal matrix and 'D' is a diagonal matrix.
  1465.  
  1466. Eigenvalue analyses are used in a wide variety of engineering, statistical and
  1467. other mathematical analyses.
  1468.  
  1469. The package includes two algorithms: Jacobi and Householder. The first is
  1470. extremely reliable but much slower than the second.
  1471.  
  1472. The code is adapted from routines in "Handbook for Automatic Computation, Vol
  1473. II, Linear Algebra" by Wilkinson and Reinsch, published by Springer Verlag. 
  1474.  
  1475.  
  1476.     Jacobi(A,D,S,V);                  // A, S symmetric; S is workspace,
  1477.                                       //    S = A is OK; V is a matrix
  1478.     Jacobi(A,D);                      // A symmetric
  1479.     Jacobi(A,D,S);                    // A, S symmetric; S is workspace,
  1480.                                       //    S = A is OK
  1481.     Jacobi(A,D,V);                    // A symmetric; V is a matrix
  1482.  
  1483.     EigenValues(A,D);                 // A symmetric
  1484.     EigenValues(A,D,S);               // A, S symmetric; S is for back
  1485.                                       //    transforming, S = A is OK
  1486.     EigenValues(A,D,V);               // A symmetric; V is a matrix
  1487.  
  1488. The values of 'A' are not changed unless 'A' is also inserted as the third
  1489. argument. If you need eigenvectors use one of the forms with matrix 'V'. The
  1490. eigenvectors are returned as the columns of 'V'.
  1491.  
  1492.  
  1493.  
  1494.  
  1495.         3.21  Sorting
  1496.         ====  =======
  1497.  
  1498. To sort the values in a matrix or vector, 'A', (in general this operation
  1499. makes sense only for vectors and diagonal matrices) use
  1500.  
  1501.     SortAscending(A);
  1502.  
  1503. or
  1504.  
  1505.     SortDescending(A);
  1506.  
  1507. I use the Shell-sort algorithm. This is a medium speed algorithm, you might
  1508. want to replace it with something faster if speed is critical and your
  1509. matrices are large.
  1510.  
  1511.  
  1512.  
  1513.         3.22  Fast Fourier transform
  1514.         ====  ==== ======= =========
  1515.  
  1516.  
  1517.    FFT(X, Y, F, G);                         // F=X and G=Y are OK
  1518.  
  1519. where X, Y, F, G are column vectors. X and Y are the real and imaginary input
  1520. vectors; F and G are the real and imaginary output vectors. The lengths of X
  1521. and Y must be equal and should be the product of numbers less than about 10
  1522. for fast execution.
  1523.  
  1524. The formula is
  1525.  
  1526.           n-1
  1527.    h[k] = SUM  z[j] exp (-2 pi i jk/n)
  1528.           j=0
  1529.  
  1530. where z[j] is stored complex and stored in X(j+1) and Y(j+1). Likewise h[k] is
  1531. complex and stored in F(k+1) and G(k+1). The fast Fourier algorithm takes
  1532. order n log(n) operations (for "good" values of n) rather than n**2 that
  1533. straight evaluation would take.
  1534.  
  1535. I use the method of Carl de Boor (1980), "Siam J Sci Stat Comput", pp 173-8.
  1536. The sines and cosines are calculated explicitly. This gives better accuracy,
  1537. at an expense of being a little slower than is otherwise possible.
  1538.  
  1539. Related functions
  1540.  
  1541.    FFTI(F, G, X, Y);                        // X=F and Y=G are OK
  1542.    RealFFT(X, F, G);
  1543.    RealFFTI(F, G, X);
  1544.  
  1545. 'FFTI' is the inverse trasform for 'FFT'. 'RealFFT' is for the case when the
  1546. input vector is real, that is Y = 0. I assume the length of X, denoted by n,
  1547. is even. The program sets the lengths of F and G to n/2 + 1. 'RealFFTI' is the
  1548. inverse of 'RealFFT'.
  1549.  
  1550.  
  1551.  
  1552.         3.23  Interface to Numerical Recipes in C
  1553.         ====  ========= == ========= ======= == =
  1554.  
  1555. This package can be used with the vectors and matrices defined in "Numerical
  1556. Recipes in C". You need to edit the routines in Numerical Recipes so that the
  1557. elements are of the same type as used in this package. Eg replace float by
  1558. double, vector by dvector and matrix by dmatrix, etc. You will also need to
  1559. edit the function definitions to use the version acceptable to your compiler.
  1560. Then enclose the code from Numerical Recipes in  extern "C" { ... }. You will
  1561. also need to include the matrix and vector utility routines.
  1562.  
  1563. Then any vector in Numerical Recipes with subscripts starting from 1 in a
  1564. function call can be accessed by a RowVector, ColumnVector or DiagonalMatrix
  1565. in the present package. Similarly any matrix with subscripts starting from 1
  1566. can be accessed by an  nricMatrix  in the present package. The class
  1567. nricMatrix is derived from Matrix and can be used in place of Matrix. In each
  1568. case, if you wish to refer to a RowVector, ColumnVector, DiagonalMatrix or
  1569. nricMatrix X in an function from Numerical Recipes, use X.nric() in the
  1570. function call.
  1571.  
  1572. Numerical Recipes cannot change the dimensions of a matrix or vector. So
  1573. matrices or vectors must be correctly dimensioned before a Numerical Recipes
  1574. routine is called.
  1575.  
  1576. For example
  1577.  
  1578.    SymmetricMatrix B(44);
  1579.    .....                             // load values into B
  1580.    nricMatrix BX = B;                // copy values to an nricMatrix
  1581.    DiagonalMatrix D(44);             // Matrices for output
  1582.    nricMatrix V(44,44);              //    correctly dimensioned
  1583.    int nrot;
  1584.    jacobi(BX.nric(),44,D.nric(),V.nric(),&nrot);
  1585.                                      // jacobi from NRIC
  1586.    cout << D;                        // print eigenvalues
  1587.  
  1588.  
  1589.  
  1590.  
  1591.         3.24  Exceptions
  1592.         ====  ==========
  1593.  
  1594. This package includes a partial implementation of exceptions for compilers
  1595. which do not support C++ exceptions. I used Carlos Vidal's article in the
  1596. September 1992 "C Users Journal" as a starting point.
  1597.  
  1598. See customising [2.2] for selecting the correct exception option.
  1599.  
  1600. See the section on error messages [4] for some notes on the messages generated
  1601. by the exceptions.
  1602.  
  1603. The rest of this section describes my exception simulation package. But see
  1604. the end of the section for controlling the action after an exception has been
  1605. generated.
  1606.  
  1607. Newmat does a partial clean up of memory following throwing an exception - see
  1608. the next section. However, the present version will leave a little heap memory
  1609. unrecovered under some circumstances. I would not expect this to be a major
  1610. problem, but it is something that needs to be sorted out.
  1611.  
  1612. The functions/macros I define are Try, Throw, Catch, CatchAll and
  1613. CatchAndThrow. Try, Throw, Catch and CatchAll correspond to try, throw, catch
  1614. and catch(...) in the C++ standard. A list of Catch clauses must be terminated
  1615. by either CatchAll or CatchAndThrow but not both. Throw takes an Exception as
  1616. an argument or takes no argument (for passing on an exception). I do not have
  1617. a version of Throw for specifying which exceptions a function might throw.
  1618. Catch takes an exception class name as an argument; CatchAll and CatchAndThrow
  1619. don't have any arguments. Try, Catch and CatchAll must be followed by blocks
  1620. enclosed in curly brackets.
  1621.  
  1622. I have added another macro Bounce to mean a rethrow, Throw(). This was
  1623. necessary to enable the package to be compatible with both my exception
  1624. package and C++ exceptions.
  1625.  
  1626. All Exceptions must be derived from a class, Exception, defined in newmat and
  1627. can contain only static variables. See the examples in newmat if you want to
  1628. define additional exceptions.
  1629.  
  1630. I have defined 5 clases of exceptions for users (there are others but I
  1631. suggest you stick to these ones):
  1632.  
  1633.    SpaceException                 Insufficient space on the heap
  1634.    ProgramException               Errors such as out of range index or
  1635.                                   incompatible matrix types or
  1636.                                   dimensions
  1637.    ConvergenceException           Iterative process does not converge
  1638.    DataException                  Errors such as attempting to invert a
  1639.                                   singular matrix
  1640.    InternalException              Probably a programming error in newmat
  1641.  
  1642. For each of these exception classes, I have defined a member function 'void
  1643. SetAction(int)'. If you call 'SetAction(1)', and a corresponding exception
  1644. occurs, you will get an error message. If there is a Catch clause for that
  1645. exception, execution will be passed to that clause, otherwise the program will
  1646. exit. If you call 'SetAction(0)' you will get the same response, except that
  1647. there will be no error message. If you call 'SetAction(-1)', you will get the
  1648. error message but the program will always exit.
  1649.  
  1650.  
  1651.  
  1652.         3.25  Cleanup after an exception
  1653.         ====  ======= ===== == =========
  1654.  
  1655. The exception mechanisms in newmat are based on the C functions setjmp and
  1656. longjmp. These functions do not call destructors so can lead to garbage being
  1657. left on the heap. (I refer to memory allocated by "new" as heap memory). For
  1658. example, when you call
  1659.  
  1660.    Matrix A(20,30);
  1661.  
  1662. a small amount of space is used on the stack containing the row and column
  1663. dimensions of the matrix and 600 doubles are allocated on the heap for the
  1664. actual values of the matrix. At the end of the block in which A is declared,
  1665. the destructor for A is called and the 600 doubles are freed. The locations on
  1666. the stack are freed as part of the normal operations of the stack. If you
  1667. leave the block using a longjmp command those 600 doubles will not be freed
  1668. and will occupy space until the program terminates.
  1669.  
  1670. To overcome this problem newmat keeps a list of all the currently declared
  1671. matrices and its exception mechanism will return heap memory when you do a
  1672. Throw and Catch.
  1673.  
  1674. However it will not return heap memory from objects from other packages. If
  1675. you want the mechanism to work with another class you will have to do four
  1676. things:
  1677.  
  1678. 1:  derive your class from class Janitor defined in except.h;
  1679.  
  1680. 2:  define a function 'void CleanUp()' in that class to return all heap
  1681. memory;
  1682.  
  1683. 3:   include the following lines in the class definition
  1684.  
  1685.       public:
  1686.          void* operator new(size_t size)
  1687.          { do_not_link=TRUE; void* t = ::operator new(size); return t; }
  1688.          void operator delete(void* t) { ::operator delete(t); }
  1689.  
  1690. 4:   be sure to include a copy constructor in you class definition, that is,
  1691. something like
  1692.  
  1693.       X(const X&);
  1694.  
  1695.  
  1696. Note that the function 'CleanUp()' does somewhat the same duties as the
  1697. destructor. However 'CleanUp()' has to do the "cleaning" for the class you are
  1698. working with and also the classes it is derived from. So it will often be
  1699. wrong to use exactly the same code for both 'CleanUp()' and the destructor or
  1700. to define your destructor as a call to 'CleanUp()'.
  1701.  
  1702.  
  1703.  
  1704.  
  1705.         3.26  Non-linear applications
  1706.         ====  ========== ============
  1707.  
  1708. Files solution.h, solution.cpp contain a class for solving for x in y = f(x)
  1709. where x is a one-dimensional continuous monotonic function. This is not a
  1710. matrix thing at all but is included because it is a useful thing and because
  1711. it is a simpler version of the technique used in the non-linear least squares.
  1712.  
  1713. Files newmatnl.h, newmatnl.cpp contain a series of classes for non-linear
  1714. least squares, to be extended to maximum likelihood in a later release.
  1715.  
  1716. Documentation for both of these is in the definition files. Simple examples
  1717. are in sl_ex.cpp and nl_ex.cpp.
  1718.  
  1719. These packages do not work with the AT&T [2.3.1] and HPUX [2.3.4] compilers
  1720. and newmatnl is questionable under Sun 4.0.1 [2.3.6].
  1721.  
  1722.  
  1723.  
  1724.         4  Error messages
  1725.         =  ===== ========
  1726.  
  1727. Most error messages are self-explanatory. The message gives the size of the
  1728. matrices involved. Matrix types are referred to by the following codes:
  1729.  
  1730.    Matrix or vector                    1
  1731.    Symmetric matrix                    5
  1732.    Band matrix                         9
  1733.    Symmetric band matrix              13
  1734.    Lower triangular matrix            17
  1735.    Lower triangular band matrix       25
  1736.    Upper triangular matrix            33
  1737.    Upper triangular band matrix       41
  1738.    Diagonal matrix                    63
  1739.    Crout matrix (LU matrix)           65
  1740.    Band LU matrix                     73
  1741.  
  1742. Other codes should not occur.
  1743.  
  1744. See the section on exceptions [3.24] for more details on the structure of the
  1745. exception classes.
  1746.  
  1747. I have defined a class Tracer that is intended to help locate the place where
  1748. an error has occurred. At the beginning of a function I suggest you include a
  1749. statement like
  1750.  
  1751.    Tracer tr("name");
  1752.  
  1753. where name is the name of the function. This name will be printed as part of
  1754. the error message, if an exception occurs in that function, or in a function
  1755. called from that function. You can change the name as you proceed through a
  1756. function with the ReName function
  1757.  
  1758.    tr.ReName("new name");
  1759.  
  1760. if, for example, you want to track progress through the function.
  1761.  
  1762.  
  1763.  
  1764.  
  1765.         5  Bugs
  1766.         =  ====
  1767.  
  1768.  
  1769. *  Small memory leaks may occur when an exception is thrown and caught.
  1770.  
  1771. *  My exception scheme is not properly linked in with the standard library
  1772. exceptions. In particular, my scheme may fail to catch out-of-memory
  1773. exceptions.
  1774.  
  1775.  
  1776.  
  1777.  
  1778.  
  1779.  
  1780.         6  List of files
  1781.         =  ==== == =====
  1782.  
  1783.  
  1784.  README          readme file
  1785.  NEWMATA  TXT    documentation file
  1786.  NEWMATB  TXT    notes on the package design
  1787.  KBRIGGS  TXT    Keith Briggs' list of matrix libraries
  1788.  
  1789.  BOOLEAN  H      boolean class definition
  1790.  CONTROLW H      control word definition file
  1791.  INCLUDE  H      details of include files and options
  1792.  MYEXCEPT H      general exception handler definitions
  1793.  NEWMAT   H      main matrix class definition file
  1794.  NEWMATAP H      applications definition file
  1795.  NEWMATIO H      input/output definition file
  1796.  NEWMATNL H      non-linear optimisation definition file
  1797.  NEWMATRC H      row/column functions definition files
  1798.  NEWMATRM H      rectangular matrix access definition files
  1799.  PRECISIO H      numerical precision constants
  1800.  SOLUTION H      one dimensional solve definition file
  1801.  
  1802.  BANDMAT  CPP    band matrix routines
  1803.  CHOLESKY CPP    Cholesky decomposition
  1804.  EVALUE   CPP    eigenvalues and eigenvector calculation
  1805.  FFT      CPP    fast Fourier transform
  1806.  HHOLDER  CPP    QR routines
  1807.  JACOBI   CPP    eigenvalues by the Jacobi method
  1808.  MYEXCEPT CPP    general error and exception handler
  1809.  NEWMAT1  CPP    type manipulation routines
  1810.  NEWMAT2  CPP    row and column manipulation functions
  1811.  NEWMAT3  CPP    row and column access functions
  1812.  NEWMAT4  CPP    constructors, redimension, utilities
  1813.  NEWMAT5  CPP    transpose, evaluate, matrix functions
  1814.  NEWMAT6  CPP    operators, element access
  1815.  NEWMAT7  CPP    invert, solve, binary operations
  1816.  NEWMAT8  CPP    LU decomposition, scalar functions
  1817.  NEWMAT9  CPP    output routines
  1818.  NEWMATEX CPP    matrix exception handler
  1819.  NEWMATNL CPP    non-linear optimisation
  1820.  NEWMATRM CPP    rectangular matrix access functions
  1821.  SORT     CPP    sorting functions
  1822.  SOLUTION CPP    one dimensional solve
  1823.  SUBMAT   CPP    submatrix functions
  1824.  SVD      CPP    singular value decomposition
  1825.  
  1826.  EXAMPLE  CPP    example of use of package
  1827.  EXAMPLE  TXT    output from example
  1828.  
  1829.  GNU      MAK    general make file for Gnu G++
  1830.  CC       MAK    general make file for AT&T, Sun and HPUX
  1831.  MS_NT    MAK    general make file for Microsoft C 8.0 (windows NT)
  1832.  WATCOM   MAK    general make file for Watcom 10
  1833.  WATCO_NT MAK    general make file for Watcom 10 (windows NT)
  1834.  EX_B     MAK    make file for example for Borland C 3.1
  1835.  EX_BC45  MAK    make file for example for Borland C 4.5 (windows NT)
  1836.  TMT_B    MAK    make file for test for Borland C 3.1
  1837.  TMT_BC45 MAK    make file for test for Borland C 4.5 (windows NT)
  1838.  TMT_Z    MAK    make file for test for Zortech
  1839.  
  1840.  SL_EX    CPP    example of OneDimSolve routine
  1841.  SL_EX    TXT    output from example
  1842.  NL_EX    CPP    example of non-linear least squares
  1843.  NL_EX    TXT    output from example
  1844.  
  1845.  
  1846. See the section on testing [2.6] for details of test files.
  1847.  
  1848.  
  1849.  
  1850.         7  Problem report form
  1851.         =  ======= ====== ====
  1852.  
  1853. Copy and paste this to your editor; fill it out and email to
  1854.     robert.davies@vuw.ac.nz
  1855.  
  1856. or
  1857.  
  1858.     Compuserve 72777,656.
  1859.  
  1860.  Version: ............... newmat08 (19 Jan 95)
  1861.  Primary site ........... SimTel
  1862.  Downloaded from: .......
  1863.  Your email address: ....
  1864.  Today's date: ..........
  1865.  Your machine: ..........
  1866.  Operating system: ......
  1867.  Compiler & version: ....
  1868.  Describe the problem - attach examples if possible:
  1869.  
  1870.  
  1871.  
  1872.  
  1873.  
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.